package com.qianye.service.impl;


import com.qianye.pojo.entity.RobotGreetRelation;
import com.qianye.mapper.RobotGreetRelationDao;
import com.qianye.service.RobotGreetRelationCoreService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;

/**
 * (RobotGreetRelation)表服务实现类
 *
 * @author makejava
 * @since 2024-09-16 23:46:09
 */
@Service("robotGreetRelationCoreService")
public class RobotGreetRelationCoreServiceImpl implements RobotGreetRelationCoreService {
    @Resource
    private RobotGreetRelationDao robotGreetRelationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public RobotGreetRelation queryById(Long id) {
        return this.robotGreetRelationDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param robotGreetRelation 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<RobotGreetRelation> queryByPage(RobotGreetRelation robotGreetRelation, PageRequest pageRequest) {
        long total = this.robotGreetRelationDao.count(robotGreetRelation);
        return new PageImpl<>(this.robotGreetRelationDao.queryAllByLimit(robotGreetRelation, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param robotGreetRelation 实例对象
     * @return 实例对象
     */
    @Override
    public RobotGreetRelation insert(RobotGreetRelation robotGreetRelation) {
        this.robotGreetRelationDao.insert(robotGreetRelation);
        return robotGreetRelation;
    }

    /**
     * 修改数据
     *
     * @param robotGreetRelation 实例对象
     * @return 实例对象
     */
    @Override
    public RobotGreetRelation update(RobotGreetRelation robotGreetRelation) {
        this.robotGreetRelationDao.update(robotGreetRelation);
        return this.queryById(robotGreetRelation.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.robotGreetRelationDao.deleteById(id) > 0;
    }
}
